/*
 * Copyright (c) 2011.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package org.skavookie.expressions

/**
 * Created by IntelliJ IDEA.
 * User: joshua
 * Date: 5/24/11
 * Time: 11:53 AM
 * To change this template use File | Settings | File Templates.
 */

abstract class NumericExpr[T](implicit num: Numeric[T]) extends Expr[T] {
	def getNumeric = num
	def +(rhs: Expr[T]): Expr[T] = PlusExpr(this, rhs)
	def -(rhs: Expr[T]): Expr[T] = MinusExpr(this, rhs)
	def *(rhs: Expr[T]): Expr[T] = TimesExpr(this, rhs)
	def unary_-(): Expr[T] = NegateExpr(this)
	def plus(rhs: Expr[T]) = this + rhs
	def minus(rhs: Expr[T]) = this - rhs
	def times(rhs: Expr[T]) = this * rhs
	def negate = -this
}

case class LiteralNumeric[T](literal: T)(implicit num: Numeric[T], implicit val manifest: Manifest[T]) extends NumericExpr[T] with TLiteral[T]
case class PlusExpr[T](lhs: Expr[T], rhs: Expr[T])(implicit num: Numeric[T]) extends NumericExpr[T]
case class MinusExpr[T](lhs: Expr[T], rhs: Expr[T])(implicit num: Numeric[T]) extends NumericExpr[T]
case class TimesExpr[T](lhs: Expr[T], rhs: Expr[T])(implicit num: Numeric[T]) extends NumericExpr[T]
case class NegateExpr[T](x: Expr[T])(implicit num: Numeric[T]) extends NumericExpr[T]
